'''
Created on 23/11/2010

@author: Nami
'''
from game.weapon.Bullet import Bullet

class Weapon(object):
    '''
    classdocs
    '''

    bullet_dic= {}

    def __init__(self,parent,d):
        '''
        Constructor
        '''
        self.weapon_id = int(d.info.weapon_id)
        self.weapon_sub_id = int(d.info.sub_id)
        self.id = "w%d_%d" % (self.weapon_id,self.weapon_sub_id)
        self.name = d.info.name
        self.active = bool(int(d.info.active))
        self.energy_to_activate = int(d.info.energy_activate)
        self.energy_to_shoot = int(d.info.energy_shoot)
        self.is_charged_shoot = bool(int(d.info.charge_shoot))
        self.charge_max = float(d.info.charge_shoot_max)
        self.charge_step = float(d.info.charge_shoot_step)
        self.cooldown = float(d.info.cooldown)
        
        self.bullet_dic = {}
        for b in d.bullets.bullet:
            new_bullet = Bullet(self,b)
            self.bullet_dic[new_bullet.id] = new_bullet
        